<html>
<head><meta charset="utf-8"><title>the next method · wg-async-foundations/stream-trait-rfc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/index.html">wg-async-foundations/stream-trait-rfc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html">the next method</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208350698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350698">(Aug 28 2020 at 14:38)</a>:</h4>
<p>So I was advocating for including the <code>next()</code> method, but in the recent lang team meeting, <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> raised the point that it makes migration from the futures crate just a bit more difficult</p>



<a name="208350736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350736">(Aug 28 2020 at 14:38)</a>:</h4>
<p>In particular, if we just move the core trait, then we can seamlessly redirect futures-core to the new trait in stdlib in a minor release with zero possibility of breakage</p>



<a name="208350755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350755">(Aug 28 2020 at 14:38)</a>:</h4>
<p>but if we add the <code>next</code> method, then there is the possibility of breakage unless people upgrade <em>both</em> futures-core <em>and</em> the futures-util library</p>



<a name="208350781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350781">(Aug 28 2020 at 14:39)</a>:</h4>
<p>eventually we're going to have to wrestle with this (and we talked about some strategies, such as <code>[cfg(accessible)]</code>)</p>



<a name="208350810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350810">(Aug 28 2020 at 14:39)</a>:</h4>
<p>but maybe we should put it off until then :)</p>



<a name="208350990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208350990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208350990">(Aug 28 2020 at 14:40)</a>:</h4>
<p>I guess the question is how many consumers of stream would be able to get by with just <code>next</code></p>



<a name="208351017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208351017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208351017">(Aug 28 2020 at 14:41)</a>:</h4>
<p>maybe <span class="user-mention" data-user-id="116883">@tmandry</span>, <span class="user-mention" data-user-id="211722">@Yoshua Wuyts</span> or <span class="user-mention" data-user-id="207781">@Lucio Franco</span> you all have opinions on this?</p>



<a name="208352559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208352559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lucio Franco <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208352559">(Aug 28 2020 at 14:52)</a>:</h4>
<p>Tokio is about to publish a 0.3 and 1.0 later this year, I think we could accept some pain for a bit. I _personally_ am kinda in the boat that we just break stuff now for the future. I think having next on the stream trait would be nice.</p>



<a name="208352611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208352611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lucio Franco <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208352611">(Aug 28 2020 at 14:53)</a>:</h4>
<p>I think <code>try_next</code> and <code>next</code> are the main ones I've seen, you can basically achieve everything with those and a while loop. I can pass this question along to the others on the team to get some feedback.</p>



<a name="208352815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208352815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208352815">(Aug 28 2020 at 14:54)</a>:</h4>
<p>Thanks.</p>



<a name="208355118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208355118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208355118">(Aug 28 2020 at 15:12)</a>:</h4>
<p>If the methods will be on the main <code>Stream</code> trait, like they are for <code>Iterator</code>, I think the longer we wait, the <strong>more</strong> code that <em>could</em> break. More <code>Ext</code> traits can appear, and be depended on. There was 1, but I now know of at least 4 that provide a <code>next</code> method: <code>futures-util</code>, <code>async-std</code>, <code>tokio</code>, and <code>futures-lite</code>.</p>



<a name="208355451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208355451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208355451">(Aug 28 2020 at 15:13)</a>:</h4>
<p>What I mean to say is, I'd be for breaking earlier than later, because it could mean less breakage overall.</p>



<a name="208359112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208359112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208359112">(Aug 28 2020 at 15:41)</a>:</h4>
<p>For <code>async-std</code> it would mean we would no longer need to depend on <code>futures-core</code> since all traits and types we use can be imported from <code>std</code> directly. Given we don't use <code>futures-util</code> but instead define our own Stream adapters we won't be affected by the same issues as other projects.</p>
<p>This needs to be discussed this with the team, but my inclination is that we'll be able to bump the MSRV for <code>async-std</code> in a minor patch (like proposed for <code>futures-{core,util}</code>), and when doing so we can use that opportunity to also switch the <code>Stream::next</code> impl.</p>



<a name="208359844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208359844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208359844">(Aug 28 2020 at 15:47)</a>:</h4>
<p>Alternatively, this could be more motivation for "high priority/low priority" methods which would unblock addition of more Iterator methods as well</p>



<a name="208360750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208360750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208360750">(Aug 28 2020 at 15:53)</a>:</h4>
<p>Specifically on <code>futures-rs</code> though: I would think that bumping the minimum Rust version in a minor patch to cause more issues than a potential mismatch between the <code>futures-core</code> and <code>futures-util</code> versions.</p>
<p>For example at work we're not able to upgrade to a recent compiler because of <a href="https://github.com/rust-lang/rust/issues/72470">https://github.com/rust-lang/rust/issues/72470</a>. This means that if all of our dependencies switch over to use <code>std::stream::Stream</code> under the hood, we'll no longer be able to update our dependencies.</p>
<p>The version mismatch issue of <code>futures-{core,util}</code> should be fixable in most projects by doing a <code>cargo update</code>. I think we're already accepting a certain degree of complications; adding <code>Stream::next</code> seems less of an issue in comparison.</p>
<p><strong>edit</strong>: To clarify, <strong>not</strong> suggesting <code>futures-rs</code> take a different approach.</p>



<a name="208366421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208366421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208366421">(Aug 28 2020 at 16:40)</a>:</h4>
<p>I don't know if this is a good idea, but futures-rs <em>could</em> use a build script to either reexport from std or define Stream itself depending on the rust version</p>



<a name="208378746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378746">(Aug 28 2020 at 18:27)</a>:</h4>
<p><span class="user-mention" data-user-id="243558">@Steven Fackler</span> we were thinking that the <code>cfg-accessible</code> feature would be ideal for that</p>



<a name="208378760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378760">(Aug 28 2020 at 18:27)</a>:</h4>
<p>i.e., if the <code>Stream</code> trait exists, don't include the <code>next</code> method</p>



<a name="208378775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378775">(Aug 28 2020 at 18:27)</a>:</h4>
<p>the main probelm is that we'll have to release a new minor version of <code>future-util</code> to make that change</p>



<a name="208378781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378781">(Aug 28 2020 at 18:27)</a>:</h4>
<p>(same with a build-rs based change)</p>



<a name="208378789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378789">(Aug 28 2020 at 18:27)</a>:</h4>
<p>Ah right</p>



<a name="208378796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378796">(Aug 28 2020 at 18:27)</a>:</h4>
<p>and some folks may not upgrade to it</p>



<a name="208378803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378803">(Aug 28 2020 at 18:27)</a>:</h4>
<p>though of course they can with <code>cargo update -p</code></p>



<a name="208378882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208378882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208378882">(Aug 28 2020 at 18:28)</a>:</h4>
<p>cfg-accessible also has MSRV issues, but a build script would avoid it</p>



<a name="208379107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208379107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208379107">(Aug 28 2020 at 18:30)</a>:</h4>
<p>yeah that's true</p>



<a name="208416445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208416445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taiki Endo <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208416445">(Aug 29 2020 at 04:20)</a>:</h4>
<p>We can add <code>next</code> method when releasing <code>futures-core</code> 1.0, so I think either is fine. (Personally, I prefer to add <code>next</code> method to <code>Stream</code>.)</p>



<a name="208416507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208416507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taiki Endo <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208416507">(Aug 29 2020 at 04:23)</a>:</h4>
<p>If you are interested, this is a (wip) list of things I would like to do in the next version of <code>futures</code>: &lt;<a href="https://gist.github.com/taiki-e/c09532b59a5bcaef7854b46b01c65f48">https://gist.github.com/taiki-e/c09532b59a5bcaef7854b46b01c65f48</a>&gt;</p>



<a name="208416553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the%20next%20method/near/208416553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taiki Endo <a href="https://rust-lang.github.io/zulip_archive/stream/249502-wg-async-foundations/stream-trait-rfc/topic/the.20next.20method.html#208416553">(Aug 29 2020 at 04:24)</a>:</h4>
<p>(I plan to open a similar one as an issue of futures-rs repo in the near future.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>